
package templateswing;

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.event.*;

public class ComboBoxPanel extends JPanel {
    public ComboBoxPanel() {
        setBorder(BorderFactory.createLineBorder(Color.RED));
        setBackground(new Color(255, 0, 255));
        myCombo=new JComboBox(comboArray);
        myCombo.setEditable(true);
        myCombo.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent event) {
                comboLabel.setText((String)myCombo.getSelectedItem());
            }
        });
        slider.addChangeListener(new ChangeListener() {
            public void stateChanged(ChangeEvent event) {
                setBackground(new Color(
                        slider.getValue(), 0, slider.getValue()));
                slider.setBackground(new Color(
                        slider.getValue(), 0, slider.getValue()));
            }
        });
        slider.setMajorTickSpacing(50);
        slider.setMinorTickSpacing(25);
        slider.setPaintTicks(true);
        slider.setPaintTrack(true);
        slider.setPaintLabels(true);
        slider.setSnapToTicks(true);
        add(myCombo);
        add(comboLabel);
        add(slider);
        
    }

    protected JComboBox myCombo;
    protected String[] comboArray={"One", "Two", "Three", "Four"};
    protected JLabel comboLabel=new JLabel("00000");
    protected JSlider slider=new JSlider(JSlider.VERTICAL, 0, 255, 255);
    protected Color panelColor;
}
